﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SomaiNordeste.FabricaRacao.DomainModel.Repository
{
    public static class DateTimeExtensionMethod
    {
        private static string FormateDate(this Insumo _insumo)
        {
            return Formate(_insumo.Date);
        }

        private static string FormateDate(this Batida _batida)
        {
            return Formate(_batida.Date);
        }

        private static string Formate(DateTime date)
        {
            //2010-11-20 13:38:43.140
            string ano = date.Year.ToString();
            string mes = date.Month > 9 ? date.Month.ToString() : "0" + date.Month.ToString();
            string dia = date.Day > 9 ? date.Day.ToString() : "0" + date.Day.ToString();
            string hora = date.Hour > 9 ? date.Hour.ToString() : "0" + date.Hour.ToString();
            string minutos = date.Minute > 9 ? date.Minute.ToString() : "0" + date.Minute.ToString();
            string segundos = date.Second > 9 ? date.Second.ToString() : "0" + date.Second.ToString();

            return ano + "-" +
                mes + "-" +
                dia +
                " " +
                hora + ":" +
                minutos + ":" +
                segundos + ":" +
                date.Millisecond;
        }
    }
}
